<?php

/**
 * Botenmarkt Front-end
 * 
 * Domain Objects
 * 
 * Ads domain object class file
 *
 * @category    botenmarkt_front
 * @package     library
 * @subpackage  domainObjects
 * @author      valerii lazarevych <valeriy.fremar@gmail.com>
 * @copyright   Copyright(c) 2012 Fremar Ukraine ltd.
 * @license     default
 * @version     $Id: Ads.php Mar 19, 2012 4:40:04 PM
 */

/**
 * Ads domain object Class
 * 
 * Represent ad like oop entity
 */
class Ads_domainObject      extends     domainObject
{
    /**
     * Ad title
     * 
     * @var string
     */
    public $title           =       null;
    
    /**
     * Ad description
     * 
     * @var string
     */
    public $description     =       null;
    
    /**
     * Ad publish online status
     * 
     * @var int(1)
     */
    public $adStatus        =       null;
    
    /**
     * Id for category of ads
     * 
     * @var int
     */
    public $category        =       null;
    
    /**
     * Boat type id
     * 
     * @var int
     */
    public $boattype        =       null;
    
    /**
     * Brand id
     * 
     * @var int
     */
    public $brand           =       null;
    
    /**
     * Boat type
     * 
     * @var string
     */
    public $type            =       null;
    
    /**
     * Boat material id
     * 
     * @var int
     */
    public $material        =       null;
    
    /**
     * Boat trailer brand id
     * 
     * @var int
     */
    public $trailer_brand   =       null;
    
    /**
     * Country id where the boat is located
     * 
     * @var int
     */
    public $country         =       null;
    
    /**
     * City name of the location of boat
     * 
     * @var string
     */
    public $city            =       null;
    
    /**
     * Length of the boat
     * 
     * @var string
     */
    public $sizes_x         =       null;
    
    /**
     * Boat width
     * 
     * @var string
     */
    public $sizes_y         =       null;
    
    /**
     * Draft 
     * 
     * @var string
     */
    public $sizes_z         =       null;
    
    /**
     * Load capacity of the boat
     * 
     * @var int
     */
    public $load_capacity   =       null;
    
    /**
     * Production year of the boat
     * 
     * @var int
     */
    public $year            =       null;
    
    /**
     * Boat the asked price
     * 
     * @var int
     */
    public $askedPrice      =       null;
    
    /**
     * Number years of garantee service the boat
     * 
     * @var int
     */
    public $garantee        =       null;
    
    /**
     * Id number the user holder this ad
     * 
     * @var int
     */
    public $advertiser      =       null;
    
    /**
     * Main ad picture
     * 
     * @var string
     */
    public $picture_1       =       null;
    
    /**
     * Picture ad #2
     * 
     * @var string
     */
    public $picture_2       =       null;
    
    /**
     * Picture ad #3
     * 
     * @var string
     */
    public $picture_3       =       null;
    
    /**
     * Picture ad #4
     * 
     * @var string
     */
    public $picture_4       =       null;
    
    /**
     * Picture ad #5
     * 
     * @var string
     */
    public $picture_5       =       null;
    
    /**
     * Picture ad #6
     * 
     * @var string
     */
    public $picture_6       =       null;
    
    /**
     * Picture ad #7
     * 
     * @var string
     */
    public $picture_7       =       null;
    
    /**
     * Picture ad #8
     * 
     * @var string
     */
    public $picture_8       =       null;
    
    /**
     * Licence to the boat
     * 
     * @var string
     */
    public $licence         =       null;
    
    
    public $stockNumber     =       null;
    public $DateTime        =       null;
    public $DateAdded       =       null;
    public $DateModified    =       null;
    public $adPrice         =       null;
    public $offeredOrAsked  =       null;
    public $views           =       null;
    public $phoneVisible    =       null;
    public $is_old          =       null;
    public $is_renewed      =       null;
    public $motor_brand     =       null;
    public $horse_power     =       null;
    public $fuel            =       null;
        
    public $parameter_1     =       null;
    public $parameter_2     =       null;
    public $parameter_3     =       null;
    public $parameter_4     =       null;
    public $parameter_5     =       null;
    public $parameter_6     =       null;
    public $parameter_7     =       null;
    public $parameter_8     =       null;
    public $parameter_9     =       null;
    public $parameter_10    =       null;        
    public $parameter_11    =       null;
    public $parameter_12    =       null;
    public $parameter_13    =       null;
    public $parameter_14    =       null;
    public $parameter_15    =       null;
    public $parameter_16    =       null;
    public $parameter_17    =       null;
    public $parameter_18    =       null;
    public $parameter_19    =       null;
    public $parameter_20    =       null;    
    public $parameter_21    =       null;
    public $parameter_22    =       null;
    public $parameter_23    =       null;
    public $parameter_24    =       null;
    public $parameter_25    =       null;
    public $parameter_26    =       null;
    public $parameter_27    =       null;
    public $parameter_28    =       null;
    public $parameter_29    =       null;
    public $parameter_30    =       null;
    public $parameter_31    =       null;
    public $parameter_32    =       null;
    public $parameter_33    =       null;
    public $parameter_34    =       null;
    public $parameter_35    =       null;
    public $parameter_36    =       null;
    public $parameter_37    =       null;
    public $parameter_38    =       null;
    public $parameter_39    =       null;
    public $parameter_40    =       null;
    public $parameter_41    =       null;
    public $parameter_42    =       null;
    public $parameter_43    =       null;
    public $parameter_44    =       null;
    public $parameter_45    =       null;
    public $parameter_46    =       null;
    public $parameter_47    =       null;
    public $parameter_48    =       null;
    public $parameter_49    =       null;
    public $parameter_50    =       null;
    public $parameter_51    =       null;
    public $parameter_52    =       null;
    public $parameter_53    =       null;
    public $parameter_54    =       null;
    public $parameter_55    =       null;
    public $parameter_56    =       null;
            
    public $paid            =       null;
    public $payStatus       =       null;
    public $payDate         =       null;
    
    
    const   OFFERED          =       'Offered';
    const   ASKED            =       'Asked';
    
    /**
     * Get ad title
     * 
     * @return string
     */
    public function adTitle()
    {
        return $this->title;
    }
    
    /**
     * Get ad views number
     * 
     * @return int
     */
    public function adViews()
    {
        return $this->views;
    }
    
    /**
     * Is ad still online?
     * 
     * @return bool
     */
    public function IsAdOnline()
    {
        return $this->adStatus;
    }
    
    /**
     * Get description of ad preview
     * 
     * @return string
     */
    public function adPreviewDescription()
    {
        return substr($this->description, '0', '100').'...';
    }
    
    /**
     * Get year vessel were made
     * 
     * @return int
     */
    public function vesselYear()
    {
        return $this->year;
    }
    
    /**
     * Get price of the boat
     * 
     * @return int
     */
    public function boatAskedPrice()
    {
        return $this->askedPrice;
    }
    
    /**
     * Get date when the boat was added
     * 
     * @return type int
     */
    public function adDateAdded()
    {
        return $this->DateAdded;
    }
    
    /**
     * Get date of last modification
     * 
     * @return int
     */
    public function adDateModified()
    {
        return $this->DateModified;
    }
    
    /**
     * Get category of boat
     * 
     * @return Categories_domainObject
     */
    public function adCategory()
    {
        if (!$this->category instanceof Categories_domainObject){
            
            $adCat  =   new Categories_domainObject();
            $adCat->find($this->category);
            $this->category =   $adCat;     }
                    
        return $this->category;
    }
    
    /**
     * Is this ad an offer or an ask
     * 
     * @return string
     */
    public function offeredOrAsked()
    {
        return $this->offeredOrAsked  ? self::ASKED  : self::OFFERED;
    }
    
    /**
     * Renew time the ad
     */
    public function reNewAd()
    {
        $this->DateTime     =   time();
        $this->is_renewed   =   '1';
        $this->save();
    }
    
    /**
     * Get an update time the ad
     * 
     * @return int
     */
    public function adRenewTime()
    {
        return $this->DateTime;
    }
    
    /**
     * Returns the object  materials_domainObject that has to do with vessel of this ad
     *  
     * @return Materials_domainObject
     */
    public function adMaterial()
    {
        if (!$this->material instanceof Materials_domainObject) {
            
            $vesselMaterial     =   new Materials_domainObject;
            $vesselMaterial->find($this->material);
            
            $this->material     =   $vesselMaterial;            }
            
        return $this->material;
    }
    
    /**
     * Get ad preview photo
     * 
     * @return string
     */
    public function adPreviewPhoto()
    {
        return $this->picture_1;
    }
    
    /**
     * Get vessel length
     * 
     * @return int
     */
    public function vesselLength()
    {
        return $this->sizes_x;
    }
    
    /**
     * Get beam athwartship
     * 
     * @return int
     */
    public function beamAthwartship()
    {
        return $this->sizes_y;
    }
    
    /**
     * Get vessel draft
     * 
     * @return int
     */
    public function vesselDraft()
    {
        return $this->sizes_z;
    }
}

